package Test;

import java.util.*;

public class Test1 {
    //Map集合里面，键是字符串，值是单列集合
    public static void main(String[] args) {
        //创建单列集合
        ArrayList<String> list1=new ArrayList<>();
        ArrayList<String> list2=new ArrayList<>();

        //添加元素
        Collections.addAll(list1,"顺德","南海","禅城");
        Collections.addAll(list2,"新会","蓬江","鹤山");

        //创建Map集合
        HashMap<String,ArrayList<String>> hs=new HashMap<>();
        //添加元素到Map集合
        hs.put("佛山",list1);
        hs.put("江门",list2);

        //遍历
        Set<Map.Entry<String, ArrayList<String>>> entries = hs.entrySet();
        for (Map.Entry<String, ArrayList<String>> entry : entries) {
            String city=entry.getKey();

            ArrayList<String> qu = entry.getValue();
            StringJoiner sj=new StringJoiner(" , ");
            for (String s : qu) {
                sj.add(s);

            }
            System.out.println(city+" = "+sj);
        }

    }

}
